#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>

struct Region {
    int left;
    int right;
} regions[50010];

// 正确的比较函数：按左端点升序排序
bool MyCompare(const Region& r1, const Region& r2) {
    if (r1.left != r2.left) {
        return r1.left < r2.left;
    }

    return r1.right < r2.right;

}

/**
 * 
 * 时间复杂度：O(nlogn)
 * 空间复杂度：O(1)
 * 区间合并
 * 
 */
int main() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d %d", &regions[i].left, &regions[i].right);
    }

    std::sort(regions, regions + n, MyCompare);

    int curLeft = regions[0].left;
    int curRight = regions[0].right;
    bool canMerge = true;

    for (int i = 1; i < n; i++) {
        if (regions[i].left > curRight) {
            canMerge = false;
            break;
        }
        // 更新当前最大右端点
        curRight = std::max(curRight, regions[i].right);
    }

    if (canMerge) {
        printf("%d %d", curLeft, curRight);
    }
    else {
        printf("no");
    }

    return 0;
}